<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>技术资料清单汇总</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                <label for="query-proCode">项目编号</label>
                                <input id="query-proCode" type="text" name="proCode" class="form-control"
                                       placeholder="请输入项目编号" style="width: 150px">
                            </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称" style="width: 150px">
                                </div>
                                <div class="form-group">
                                    <label for="query-special">类型</label>
                                    <select id="query-special" class="form-control" name="special">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${special}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分" >
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    $(function () {

        table = js.table.init({
            url: ctx + "tecard/list",
            showExport: false,
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode', width: '150'},
                {title: "项目名称", field: 'proName'},
                {title: "专业", field: 'special', width: '180'},
                {title: "部分", field: 'part', width: '180'},
            ]
        });
    });

    initChildTable = function (index, row, $detail) {
        let childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: ctx + "summary/into",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            responseHandler: function (res) {
                if (res.type === "SUCCESS") {
                    return res.data;
                }
                js.modal.warning(res.msg);
                return {rows: [], total: 0};
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '任务内容',field: 'name'},
                {title: "操作",
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs" onclick="receiveCard('+js.jsonStringify(row)+')"> 查看</a> ');
                        return actions.join('');
                    }
                }

            ]
        });
    };
</script>
</body>
</html>
